﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BE;

namespace DAL
{
	internal abstract class ALbumPicker
	{
		public const int ALBUM_ID = 0;
		public const int ALBUM_ARTIST = 1;
		public const int ALBUM_TITLE = 2;
		public const int ALBUM_GENRES = 3;
		public const int ALBUM_YEAR = 4;
		public const int ALBUM_COST = 5;
		public const int ALBUM_PICTURE = 6;
		//The Albumpicker class is the base class for all albumpickers
		//the workstring is the core of this class
		//when extending the AlbumPicker class the workstring function will be defined to you to work with as you see fit
		//return null if you don't want the album to be in the list
		internal abstract Album workString( string line );
		internal Album stringToAlbum( string line )
		{
			return AlbumStringToAlbum(SplitAlbumString( line ));
		}
		internal static string[] SplitAlbumString(string line)
		{
			return line.Split('|');
		}

		internal static Album AlbumStringToAlbum(string[] albumProps)
		{
			string[] genres = albumProps[ALBUM_GENRES].Split( ',' );
			int[] intGenres = new int[genres.Length];
			for ( int i = 0; i < genres.Length; i++ )
			{
				intGenres[i] = Convert.ToInt32( genres[i] );
			}
			return new Album( Convert.ToInt32( albumProps[ALBUM_ID] ), albumProps[ALBUM_PICTURE], albumProps[ALBUM_ARTIST], albumProps[ALBUM_TITLE], intGenres, Convert.ToInt32( albumProps[ALBUM_YEAR] ), Convert.ToDecimal( albumProps[ALBUM_COST] ) );
		}
	}


}
